package com.exam.project.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.exam.framework.aspectj.lang.annotation.Log;
import com.exam.framework.aspectj.lang.enums.BusinessType;
import com.exam.project.business.domain.ExamStudent;
import com.exam.project.business.service.IExamStudentService;
import com.exam.framework.web.controller.BaseController;
import com.exam.framework.web.domain.AjaxResult;
import com.exam.common.utils.poi.ExcelUtil;
import com.exam.framework.web.page.TableDataInfo;

/**
 * 考试关联用户表Controller
 * 
 * @author qiuwenbing
 * @date 2025-04-03
 */
@RestController
@RequestMapping("/business/examstudent")
public class ExamStudentController extends BaseController
{
    @Autowired
    private IExamStudentService examStudentService;

    /**
     * 查询考试关联用户表列表
     */
    @PreAuthorize("@ss.hasPermi('business:examstudent:list')")
    @GetMapping("/list")
    public TableDataInfo list(ExamStudent examStudent)
    {
        startPage();
        List<ExamStudent> list = examStudentService.selectExamStudentList(examStudent);
        return getDataTable(list);
    }

    /**
     * 导出考试关联用户表列表
     */
    @PreAuthorize("@ss.hasPermi('business:examstudent:export')")
    @Log(title = "考试关联用户表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExamStudent examStudent)
    {
        List<ExamStudent> list = examStudentService.selectExamStudentList(examStudent);
        ExcelUtil<ExamStudent> util = new ExcelUtil<ExamStudent>(ExamStudent.class);
        util.exportExcel(response, list, "考试关联用户表数据");
    }

    /**
     * 获取考试关联用户表详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:examstudent:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(examStudentService.selectExamStudentById(id));
    }

    /**
     * 新增考试关联用户表
     */
    @PreAuthorize("@ss.hasPermi('business:examstudent:add')")
    @Log(title = "考试关联用户表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExamStudent examStudent)
    {
        return toAjax(examStudentService.insertExamStudent(examStudent));
    }

    /**
     * 修改考试关联用户表
     */
    @PreAuthorize("@ss.hasPermi('business:examstudent:edit')")
    @Log(title = "考试关联用户表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExamStudent examStudent)
    {
        return toAjax(examStudentService.updateExamStudent(examStudent));
    }

    /**
     * 删除考试关联用户表
     */
    @PreAuthorize("@ss.hasPermi('business:examstudent:remove')")
    @Log(title = "考试关联用户表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(examStudentService.deleteExamStudentByIds(ids));
    }
}
